//
//  JXRequest.swift
//  Demo
//
//  Created by xiu on 2020/4/20.
//  Copyright © 2020 111. All rights reserved.
//

import Foundation
import Alamofire

public enum JXRequest: JXRequestProtocol {
    // 通用接口
    case custom(path:String, param:[String : Any], isEncrypt:JXUrlEncryptType)
    public var host: String {
        return JXNetwork.apiHost
    }
    
    public var path: String {
        switch self {
        case .custom(let path,_,_):
            return path
        }
    }
    
    public var params: [String : Any]? {
        switch self {
        case .custom(_,let param,_):
            return param
        }
    }
    
    public var method: HTTPMethod {
        return .post
    }
    
    public var encrypt: JXUrlEncryptType {
        switch self {
        case .custom(_,_,let isencrypt):
            return isencrypt
        }
    }
    
    public var contentType: JXContentType {
        return .json
    }
    
    public var headers: Dictionary<String, String>? {
        return ["Content-Type":"application/json"]
    }
    
    public var headerFiles: Dictionary<String, String>? {
        return nil
    }
    
    public func response(completionHandler: @escaping CompletionHandler) {
        JXNetwork.request(self,completionHandler)
    }
}

